---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  5_SingleRestrictions_ReadInCps.log
  log type:  text
 opened on:  16 Apr 2018, 10:10:53

. ***************************************************************************;
. * READ IN CPS DATA FROM IPUMS FOR EITC EMPLOYMENT PROJECT ;
. ***************************************************************************;
. local beginTime "DateTime: $S_DATE $S_TIME";

. set more off ;

. set linesize 200 ;

. set mem 5g ;
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. cd "$dataDir" ;

.                 * USE THE SAME FILE WorkingFullCPSTEMP THAT IS PRODUCED BY 1_SingleWomen_ReadInCps ;
.                                 ***************************************************************************;
. * DEFINE STUFF THAT WE DONT EVER WANT TO COMMENT OUT. ;
. ***************************************************************************;
. local technical_vars "year serial relate famunit pernum wtsupp spmwt hwtsupp";

. local demographic_vars "age marst race sex hispan educ
>         statefip wkswork1 uhrswork wksunem1 whynwly mthwelfr schlcoll
>         nfams nmothers momloc momrule poploc poprule foodstmp
>         pubhous rentsub heatsub lunchsub offtotval stampval heatval union
>         qincwage poverty offcutoff offpov spmpov spmthresh spmtotres spmeitc 
>         spmfedtaxac spmfedtaxbc" ;

. local income_vars "inctot incwage incbus incfarm incss incwelfr incgov 
>         incaloth incretir incssi incdrt incint incunemp incwkcom incvet incsurv 
>         incdisab incdivid incrent inceduc incchild incalim incasist incother  ";

. ***************************************************************************;
. * BUILDING CHILDREN ;
. *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++;
. local generationvars "age sex schlcoll marst whynwly wtsupp `income_vars'" ;

.  * YOUNGEST GENERATION CHILD FILE ;
. use WorkingFullCPSTEMP ;

. keep year serial pernum momloc poploc `generationvars' ;

. foreach var of varlist pernum momloc poploc `generationvars'  {;
  2.         rename `var' `var'G0 ;
  3.         };

. gen pernum = momlocG0 ;

. replace pernum = poplocG0 if momlocG0==0 & poplocG0>0 ;
(104,938 real changes made)

. drop if pernum == 0 ;
(3,890,213 observations deleted)

. save childrens, replace ;
(note: file childrens.dta not found)
file childrens.dta saved

. clear ;

. foreach gen in 1 2 3 4 5 {;
  2.         use WorkingFullCPSTEMP ;
  3.         keep year serial pernum momloc poploc `generationvars' ;
  4.         foreach var of varlist momloc poploc `generationvars' {;
  5.                 rename `var' `var'G`gen' ;
  6.                 };
  7.         sort year serial pernum ;
  8.         merge 1:m year serial pernum using childrens ;
  9.         drop if _merge == 1 ;
 10.         drop _merge ;
 11.         rm childrens.dta ;
 12.         rename pernum pernumG`gen' ;
 13.         gen pernum = momlocG`gen' ;
 14.         replace pernum = poplocG`gen' if momlocG`gen'==0 ;
 15.         count if pernum >0 & pernum!=. ;
 16.         * BREAK LOOK IF WE CANNOT FIND ANY NEW PARENTS ;
.         if r(N)==0 {;
 17.                 continue, break ;
 18.                 };
 19.         sort year serial pernum ;
 20.         save childrens, replace ;
 21.         clear ;
 22.         };
(note: variable pernum was byte, now float to accommodate using data's values)
(label incdivid_lbl already defined)
(label incfarm_lbl already defined)
(label incbus_lbl already defined)
(label incwage_lbl already defined)
(label inctot_lbl already defined)
(label whynwly_lbl already defined)
(label schlcoll_lbl already defined)
(label marst_lbl already defined)
(label sex_lbl already defined)
(label age_lbl already defined)
(label wtsupp_lbl already defined)

    Result                           # of obs.
    -----------------------------------------
    not matched                     4,909,420
        from master                 4,909,420  (_merge==1)
        from using                          0  (_merge==2)

    matched                         2,185,970  (_merge==3)
    -----------------------------------------
(4,909,420 observations deleted)
(7,204 real changes made)
  76,608
(note: file childrens.dta not found)
file childrens.dta saved
(note: variable pernum was byte, now float to accommodate using data's values)
(label incdivid_lbl already defined)
(label incfarm_lbl already defined)
(label incbus_lbl already defined)
(label incwage_lbl already defined)
(label inctot_lbl already defined)
(label whynwly_lbl already defined)
(label schlcoll_lbl already defined)
(label marst_lbl already defined)
(label sex_lbl already defined)
(label age_lbl already defined)
(label wtsupp_lbl already defined)

    Result                           # of obs.
    -----------------------------------------
    not matched                     8,136,723
        from master                 6,027,361  (_merge==1)
        from using                  2,109,362  (_merge==2)

    matched                            76,608  (_merge==3)
    -----------------------------------------
(6,027,361 observations deleted)
(2,109,362 missing values generated)
(125 real changes made)
  765
(note: file childrens.dta not found)
file childrens.dta saved
(note: variable pernum was byte, now float to accommodate using data's values)
(label wtsupp_lbl already defined)
(label age_lbl already defined)
(label sex_lbl already defined)
(label marst_lbl already defined)
(label schlcoll_lbl already defined)
(label whynwly_lbl already defined)
(label inctot_lbl already defined)
(label incwage_lbl already defined)
(label incbus_lbl already defined)
(label incfarm_lbl already defined)
(label incdivid_lbl already defined)

    Result                           # of obs.
    -----------------------------------------
    not matched                     8,260,891
        from master                 6,075,686  (_merge==1)
        from using                  2,185,205  (_merge==2)

    matched                               765  (_merge==3)
    -----------------------------------------
(6,075,686 observations deleted)
(2,185,205 missing values generated)
(0 real changes made)
  0

. gen generation = .;
(2,185,970 missing values generated)

. replace generation = 1 if ageG1!=. & momlocG0!=. & momlocG0>0 & sexG1==2 & (ageG1>=21&ageG1<=48) ;
(1,704,483 real changes made)

. replace generation = 2 if ageG2!=. & momlocG1!=. & momlocG1>0 & sexG2==2 & (ageG2>=21&ageG2<=48) & generation==.;
(6,379 real changes made)

. replace generation = 3 if ageG3!=. & momlocG2!=. & momlocG2>0 & sexG3==2 & (ageG3>=21&ageG3<=48) & generation==.;
(1 real change made)

. tab generation ;

 generation |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |  1,704,483       99.63       99.63
          2 |      6,379        0.37      100.00
          3 |          1        0.00      100.00
------------+-----------------------------------
      Total |  1,710,863      100.00

. * PERNUM WILL BE HOW WE MERGE CHILD TO MOM ;
. drop pernum ;

. gen pernum = . ;
(2,185,970 missing values generated)

. replace pernum = momlocG0 if generation==1 ;
(1,704,483 real changes made)

. replace pernum = momlocG1 if generation==2 ;
(6,379 real changes made)

. replace pernum = momlocG2 if generation==3 ;
(1 real change made)

. drop if pernum == . ;
(475,107 observations deleted)

. * FINALLY THE CHILD DEMOS WE WANT TO BRINK ALONG ;
. foreach var in `generationvars' {;
  2.         rename `var'G0 `var' ;
  3.         };

. keep year serial pernum `generationvars' ;

. gen qualChild = 1 if (age<=18 | (age>18 & age<24 & (schlcoll==1|schlcoll==3))) ;
(102,501 missing values generated)

. * NUMBER OF CHILDREN BY AGE ;
. local agelow  "0 0 6  15";

. local agehigh "1 5 14 24";

. foreach i of numlist 1(1)4 {;
  2.         local al : word `i' of `agelow' ;
  3.         local ah : word `i' of `agehigh' ;
  4.         gen childAgeBin_`al'_`ah' = (age>=`al' & age<=`ah' & qualChild==1);
  5.         };

. summ childAgeBin_* ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
childAgeBi~1 |  1,710,863    .0900218    .2862131          0          1
childAgeBi~5 |  1,710,863    .2950452    .4560632          0          1
childAgeB~14 |  1,710,863    .4549529    .4979668          0          1
childAgeB~24 |  1,710,863      .19009    .3923721          0          1

. * WE NEED THE WEIGHTS FROM CHILDREN TO CONSTRUCT INDIVIDUAL ESTIMATES OF POVERTY ;
. rename wtsupp chldwt ;

. * INCOME VARIABLES FOR CHILDREN. SUMMATION ACROSS K ;
. gen temp = 0 ;

. foreach var of varlist `income_vars' {;
  2.         if "`var'" != "inctot" {;
  3.                 qui replace temp = temp + `var' ;
  4.                 local name = substr("`var'",4,.) ;
  5.                 rename `var' chld`name' ;
  6.                 local chldinc_vars "`chldinc_vars' chld`name'";
  7.                 local name ;
  8.                 };
  9.         };

. rename temp chldtot ;

. drop inctot ;

. local chldinc_vars "`chldinc_vars' chldtot";

. summ `chldinc_vars' ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
    chldwage |  1,710,863    788.9181    4064.792          0     688117
     chldbus |  1,710,863    13.03729    752.9868     -12999     446853
    chldfarm |  1,710,863    2.810318    520.4826      -8000     360886
      chldss |  1,710,863    30.90076    486.1391          0      50000
   chldwelfr |  1,710,863    6.603749    169.4674          0      25000
-------------+---------------------------------------------------------
     chldgov |  1,710,863    2.035601    91.61783          0      29999
   chldaloth |  1,710,863    7.773147    197.1771          0      75000
   chldretir |  1,710,863    .5526796    105.4993          0      60000
     chldssi |  1,710,863    12.29722    278.0941          0      25000
     chlddrt |  1,710,863    1.279976    107.1919      -7200      50000
-------------+---------------------------------------------------------
     chldint |  1,710,863    17.21475     407.396          0      85606
   chldunemp |  1,710,863    4.263671    168.4922          0      31136
   chldwkcom |  1,710,863     .933409    119.0245          0      99961
     chldvet |  1,710,863    .5046704    89.86432          0      90000
    chldsurv |  1,710,863    1.959776    234.9071          0      89702
-------------+---------------------------------------------------------
   chlddisab |  1,710,863    1.750908    172.2809          0      75000
   chlddivid |  1,710,863    4.360519    235.8266          0      75000
    chldrent |  1,710,863    1.927032    231.0882      -7500      87000
    chldeduc |  1,710,863    64.34131    862.4989          0      80000
   chldchild |  1,710,863    5.582259    190.7815          0      41000
-------------+---------------------------------------------------------
    chldalim |  1,710,863    .0525717    18.19973          0      16000
   chldasist |  1,710,863    1.096734    134.7438          0      60846
   chldother |  1,710,863    2.294062    94.84021          0      51238
     chldtot |  1,710,863    972.4906    4525.307      -9079     740987

. sort year serial pernum ;

. collapse (sum) qualChild childAgeBin_* chldwt `chldinc_vars', by(year serial pernum) ;

. replace year = year -1 ;
(832,767 real changes made)

. foreach var of varlist childAgeBin_* {;
  2.         replace `var' = 1 if `var' >1 ;
  3.         };
(7,241 real changes made)
(116,793 real changes made)
(216,978 real changes made)
(66,969 real changes made)

. sort year serial pernum ;

. save childrensFAMILY, replace ;
(note: file childrensFAMILY.dta not found)
file childrensFAMILY.dta saved

. clear ;

. ***************************************************************************;
. * NOW LETS CONSTRUCT OUR SAMPLE OF WOMEN. ;
. ***************************************************************************;
. use WorkingFullCPSTEMP ;

. keep `technical_vars' `demographic_vars' `income_vars' ;

. sort year serial famunit;

. * HOUSEHOLD SIZE - TOTAL ;
. by year serial: gen byte hhsize = _N ;

. summ hhsize ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
      hhsize |  6,076,183     3.54488    1.709528          1         26

. * FAMILY SIZE ;
. by year serial famunit: gen byte famsize = _N ;

. summ famsize ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     famsize |  6,076,183    3.392119    1.737631          1         25

. tab hhsize famsize if hhsize<=10 & famsize<=10 ;

           |                                                    famsize
    hhsize |         1          2          3          4          5          6          7          8          9         10 |     Total
-----------+--------------------------------------------------------------------------------------------------------------+----------
         1 |   526,311          0          0          0          0          0          0          0          0          0 |   526,311 
         2 |   174,172  1,203,158          0          0          0          0          0          0          0          0 | 1,377,330 
         3 |    62,807     60,040  1,063,269          0          0          0          0          0          0          0 | 1,186,116 
         4 |    37,078     11,150     57,096  1,368,164          0          0          0          0          0          0 | 1,473,488 
         5 |    18,678      4,502      7,965     37,940    777,710          0          0          0          0          0 |   846,795 
         6 |     9,606      1,812      3,156      4,796     20,350    334,302          0          0          0          0 |   374,022 
         7 |     4,825        624      1,215      1,668      2,660      9,882    133,336          0          0          0 |   154,210 
         8 |     2,331        268        483        828        910      1,248      4,564     58,720          0          0 |    69,352 
         9 |     1,139        108        168        240        380        300        693      2,264     27,558          0 |    32,850 
        10 |       839         60         78         76        150        150        252        400      1,395     13,690 |    17,090 
-----------+--------------------------------------------------------------------------------------------------------------+----------
     Total |   837,786  1,281,722  1,133,430  1,413,712    802,160    345,882    138,845     61,384     28,953     13,690 | 6,057,564 


. * FAMILY KIDS ;
. gen temp = (age<=18 | (age>18 & age<24 & (schlcoll==1|schlcoll==3))) ;

. by year serial famunit: egen byte famkids = total(temp) ;

. drop temp ;

. summ famkids ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     famkids |  6,076,183    1.407087    1.434004          0         18

. foreach r in 201 501 701 1001 1113 1114 1115 1241 1260 {;
  2.         gen relate_`r' = relate==`r' ;
  3.         } ;

. foreach var of varlist relate_* {;
  2.         by year serial : egen temp = total(`var') ;
  3.         replace `var' = temp ;
  4.         drop temp ;
  5.         };
(2,904,086 real changes made)
(125,861 real changes made)
(113,725 real changes made)
(359,259 real changes made)
(27,375 real changes made)
(129,862 real changes made)
(73,062 real changes made)
(19,794 real changes made)
(174,440 real changes made)

. *summ relate_* ;
. gen temp = 0 ;

. foreach var of varlist `income_vars' {;
  2.         if "`var'" != "inctot" {;
  3.                 qui replace temp = temp + `var' ;
  4.                 };
  5.         };

. by year serial famunit : egen faminc = total(temp) ;

. drop temp ;

. *summ famunit `faminc_vars' ;
. * EMPLOYED - NOTE THAT THIS IS INDIVIDUAL SPECIFIC. ;
. gen byte employed = incwage > 0 & incwage != .;

. *tab employed ;
. * SEX ;
. gen byte female = sex==2 ;

. *tab year female ;
. * CREATE UNIFORM EDUCATION BINS ;
. gen byte hgc = . ;
(6,076,183 missing values generated)

. replace hgc = 11 if floor(educ/10) < 7;
(2,539,460 real changes made)

. replace hgc = 12 if floor(educ/10) == 7;
(1,527,290 real changes made)

. replace hgc = 13 if floor(educ/10) > 7 & floor(educ/10) < 11;
(1,050,615 real changes made)

. replace hgc = 16 if floor(educ/10) == 11;
(621,007 real changes made)

. replace hgc = 17 if floor(educ/10) >= 12 & floor(educ/10) < 90 ;
(337,811 real changes made)

. *tab year hgc , missing;
. * TAX YEAR ;
. replace year = year - 1;
(6,076,183 real changes made)

. * ------------- RESTRICTIONS --------------- ;
. * KEEP IF FEMALE ;
. keep if female == 1 ;
(2,938,334 observations deleted)

. count ;
  3,137,849

. * KEEP IF UNMARRIED ;
. drop if marst == 1 | marst == 2 ;
(1,294,863 observations deleted)

. count ;
  1,842,986

. * AGE RESTRICTION - NEED THIS TO BE HIGHER THAN QUAL AGE;
. keep if age >= 21 & age <= 48 ;
(1,360,707 observations deleted)

. count ;
  482,279

. * DROP IF THE REASON DIDNT WORK LAST YEAR WAS SICKNESS, DISABILITY, 
> *       GOING TO SCHOOL ;
. *drop if whynwly==2 | whynwly==4 ;
. count ;
  482,279

. * ------------- RESTRICTIONS --------------- ;
. * FAMILY SPECIFIC CHILDREN ;
. sort year serial pernum ;

. merge 1:1 year serial pernum using childrensFAMILY ;
(note: variable pernum was byte, now float to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                       912,928
        from master                   281,220  (_merge==1)
        from using                    631,708  (_merge==2)

    matched                           201,059  (_merge==3)
    -----------------------------------------

. drop if _merge ==2 ;
(631,708 observations deleted)

. drop _merge ;

. foreach var of varlist qualChild childAgeBin_* {;
  2.         replace `var' = 0 if `var' == . ;
  3.         };
(281,220 real changes made)
(281,220 real changes made)
(281,220 real changes made)
(281,220 real changes made)
(281,220 real changes made)

. summ qualChild childAgeBin_* ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
   qualChild |    482,279    .7262083    1.096864          0         12
childAgeBi~1 |    482,279    .0527744    .2235831          0          1
childAgeBi~5 |    482,279    .1591651    .3658304          0          1
childAgeB~14 |    482,279    .2462123    .4308041          0          1
childAgeB~24 |    482,279    .1227816    .3281867          0          1

. capture rm childrensFAMILY.dta ;

. capture rm childrensHOUSEHOLD.dta ;

. local i = 1 ;

. foreach var of varlist `income_vars' {;
  2.         local name = substr("`var'",4,.) ;
  3.         egen fam`name' = rowtotal(`var' chld`name') ;
  4.         local faminc_vars "`faminc_vars' fam`name'";
  5.         local name ;
  6.         };

. summ `faminc_vars' ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
      famtot |    482,279    20767.06    24336.58     -16999    1000000
     famwage |    482,279    17415.12    22853.52          0    1000000
      fambus |    482,279    460.4131    5114.973     -18000     502982
     famfarm |    482,279    30.92765    2501.042     -14000     500000
       famss |    482,279    362.1138    2136.555          0      69360
-------------+---------------------------------------------------------
    famwelfr |    482,279    315.0601    1265.754          0      44240
      famgov |    482,279    24.22884     329.094          0      29999
    famaloth |    482,279    104.2816    875.9709          0      93600
    famretir |    482,279    37.21854    847.5705          0      84000
      famssi |    482,279    196.0775    1223.145          0      50000
-------------+---------------------------------------------------------
      famdrt |    482,279    23.66427    661.8987      -9000      75000
      famint |    482,279    220.5376    1772.857          0     121638
    famunemp |    482,279    137.0687    1118.744          0      93500
    famwkcom |    482,279    31.42225    655.0171          0      69544
      famvet |    482,279    18.23968    572.8372          0      92964
-------------+---------------------------------------------------------
     famsurv |    482,279    55.27325    1547.394          0     199998
    famdisab |    482,279     42.4766    859.8322          0      80000
    famdivid |    482,279    79.86203    1115.984          0     125000
     famrent |    482,279    73.25837    1551.816      -9700     219531
     fameduc |    482,279    384.1685    2202.116          0      87000
-------------+---------------------------------------------------------
    famchild |    482,279    499.8769    2202.235          0      92000
     famalim |    482,279    55.89426    1211.361          0      91800
    famasist |    482,279      114.97    1437.772          0      89342
    famother |    482,279    33.37146    657.9409          0      69000

. ***************************************************************************;
. * RUN THROUGH TAXSIM ;
. ***************************************************************************;
. * STATE ;
. gen byte state = . ;
(482,279 missing values generated)

. replace state = statefip   if statefip <= 2 ;
(11,899 real changes made)

. replace state = statefip-1 if statefip >= 4  & statefip <= 6 ;
(59,523 real changes made)

. replace state = statefip-2 if statefip >= 8  & statefip <= 13 ;
(61,756 real changes made)

. replace state = statefip-3 if statefip >= 15 & statefip <= 42 ;
(258,221 real changes made)

. replace state = statefip-4 if statefip >= 44 & statefip <= 51 ;
(68,021 real changes made)

. replace state = statefip-5 if statefip >= 53 & statefip <= 56 ;
(22,859 real changes made)

. *tab state, missing ;
. gen byte depx = min(qualChild, 5) ;

. gen byte depchild = depx ;

. gen byte mstat = 1 ;

. gen pwages = max(incwage+incbus+incfarm,0) ;

. gen byte swages = 0 ;

. gen byte dividends = 0 ;

. gen byte agex=0 ;

. gen gssi = incss+incssi+incsurv+incdisab;

. gen pensions = incretir;

. gen ui = incunemp;

. gen otherprop = min(incwage+incbus+incfarm,0) +  
>         incaloth + incalim + incother + incdrt + incint + incdivid + incrent ;

. gen transfers = incwelfr+incgov+incwkcom+incvet+inceduc+incchild+incasist;

. sort year serial ;

. save cpsBeforeTaxsim_singleRestrictions, replace ;
file cpsBeforeTaxsim_singleRestrictions.dta saved

. keep year serial pernum state agex depx depchild mstat 
>         pwages swages dividends gssi pensions ui otherprop transfers;

. capture rm msg.txt;

. capture rm taxsim_out.dta;

. ankurs_taxsim, full replace;
begin taxsim9.ado on 16 Apr 2018 (version 9.0)
TAXSIM results will be merged to original file
TAXSIM results will be saved in taxsim_out.dta
Full Intermediate Calculations Requested
Marginal rate with respect to primary earner
Variable rentpaid is not in the dataset.  Generating rentpaid = 0 
Variable proptax is not in the dataset.  Generating proptax = 0 
Variable otheritem is not in the dataset.  Generating otheritem = 0 
Variable childcare is not in the dataset.  Generating childcare = 0 
Variable mortgage is not in the dataset.  Generating mortgage = 0 
Variable stcg is not in the dataset.  Generating stcg = 0 
Variable ltcg is not in the dataset.  Generating ltcg = 0 
482279 records out of 482279 are left for taxsim to process
 
TAXSIM results are being merged with workspace by taxsimid
(note: variable year was int, now float to accommodate using data's values)
(note: variable state was byte, now float to accommodate using data's values)
 

. capture rm msg.txt;

. capture rm taxsim_out.dta;

. keep year serial pernum fiitax fica siitax v25 v39 v22 v23 v19 ;

. rename v25 fedEIC;

. rename v39 stEIC ;

.   rename v22 ctc ;

. rename v23 actc ;

. rename v19 fedRegTax ;

. sort year serial pernum ;

. save CYtaxsim, replace ;
(note: file CYtaxsim.dta not found)
file CYtaxsim.dta saved

. clear ;

. use cpsBeforeTaxsim_singleRestrictions ;

. keep year serial pernum state agex depx depchild mstat 
>         pwages swages dividends gssi pensions ui otherprop transfers;

. sort year;

. merge year using cpi;
(note: you are using old merge syntax; see [D] merge for new syntax)
variable year does not uniquely identify observations in the master data

. keep if _merge == 3 ;
(66 observations deleted)

. drop _merge ;

. rename cpi currentYearCpi ;

. replace year = year - 1 ;
(482,279 real changes made)

. sort year;

. merge year using cpi;
(note: you are using old merge syntax; see [D] merge for new syntax)
variable year does not uniquely identify observations in the master data

. keep if _merge == 3 ;
(66 observations deleted)

. drop _merge ;

. rename cpi priorYearCpi ;

. foreach dollar of varlist pwages swages gssi 
>                 otherprop pensions transfers ui {;
  2.         replace `dollar' = `dollar' * (priorYearCpi/currentYearCpi);
  3.         };
(388,241 real changes made)
(0 real changes made)
(35,022 real changes made)
(184,427 real changes made)
(2,817 real changes made)
(133,289 real changes made)
(17,501 real changes made)

. capture rm msg.txt;

. capture rm taxsim_out.dta;

. ankurs_taxsim, full replace;
begin taxsim9.ado on 16 Apr 2018 (version 9.0)
TAXSIM results will be merged to original file
TAXSIM results will be saved in taxsim_out.dta
Full Intermediate Calculations Requested
Marginal rate with respect to primary earner
Variable rentpaid is not in the dataset.  Generating rentpaid = 0 
Variable proptax is not in the dataset.  Generating proptax = 0 
Variable otheritem is not in the dataset.  Generating otheritem = 0 
Variable childcare is not in the dataset.  Generating childcare = 0 
Variable mortgage is not in the dataset.  Generating mortgage = 0 
Variable stcg is not in the dataset.  Generating stcg = 0 
Variable ltcg is not in the dataset.  Generating ltcg = 0 
482279 records out of 482279 are left for taxsim to process
 
TAXSIM results are being merged with workspace by taxsimid
(note: variable year was int, now float to accommodate using data's values)
(note: variable state was byte, now float to accommodate using data's values)
 

. capture rm msg.txt;

.  capture rm taxsim_out.dta;

. keep year serial pernum v25 v39 v22 v23 v19 priorYearCpi currentYearCpi ;

. rename v25 fedEIC_ly;

. rename v39 stEIC_ly;

.   rename v22 ctc_ly;

. rename v23 actc_ly;

. rename v19 fedRegTax_ly ;

. foreach dollar of varlist fedEIC_ly stEIC_ly ctc_ly actc_ly fedRegTax_ly {;
  2.         replace `dollar' = `dollar' * (currentYearCpi/priorYearCpi);
  3.         };
(136,256 real changes made)
(31,333 real changes made)
(55,935 real changes made)
(27,513 real changes made)
(304,906 real changes made)

. drop priorYearCpi currentYearCpi ;

. replace year = year + 1 ;
(482,279 real changes made)

. sort year serial pernum;

. save LYtaxsim, replace ;
(note: file LYtaxsim.dta not found)
file LYtaxsim.dta saved

. clear ;

. use cpsBeforeTaxsim_singleRestrictions ;

. merge 1:1 year serial pernum using CYtaxsim ;
(note: variable year was int, now float to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                           482,279  (_merge==3)
    -----------------------------------------

. drop _merge ;

. merge 1:1 year serial pernum using LYtaxsim ;

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                           482,279  (_merge==3)
    -----------------------------------------

. drop _merge ;

. drop depx depchild mstat pwages swages dividends gssi pensions ui 
>         otherprop transfers;

. *rm cpsBeforeTaxsim.dta ;
. rm CYtaxsim.dta ;

. rm LYtaxsim.dta ;

. local taxsim_output "fiitax fica siitax fedEIC stEIC ctc actc fedRegTax 
>         fedEIC_ly stEIC_ly ctc_ly actc_ly fedRegTax_ly" ;

.         ***************************************************************************;
. * INFLATION ;
. ***************************************************************************;
. sort year;

. merge year using cpi;
(note: you are using old merge syntax; see [D] merge for new syntax)
variable year does not uniquely identify observations in the master data

. tab _merge;

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          2 |         66        0.01        0.01
          3 |    482,279       99.99      100.00
------------+-----------------------------------
      Total |    482,345      100.00

. keep if _merge == 3 ;
(66 observations deleted)

. drop _merge ;

. foreach dollar of varlist `income_vars' `taxsim_output' 
>                 stampval heatval `faminc_vars' `chldinc_vars' faminc {;
  2.         qui replace `dollar' = `dollar' * (232.957/cpi);
  3.         };

. replace heatval = 0 if heatval==.;
(22,839 real changes made)

. replace heatval = heatval*(1+qualChild)/(hhsize) ;
(10,835 real changes made)

. replace stampval = 0 if stampval==. ;
(0 real changes made)

. replace stampval = stampval*(1+qualChild)/(hhsize) ;
(39,057 real changes made)

. gen atti = inctot+stampval+heatval-fiitax-siitax-fica ;

. summ ;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
        year |    482,279     1997.43    10.05526       1979       2013
      serial |    482,279    42088.54    25955.78          1      99984
     hwtsupp |    482,279    1593.496    951.6336          0   17957.53
    statefip |    482,279    27.38646    15.55252          1         56
     pubhous |    482,279      .58473    .5891778          0          2
-------------+---------------------------------------------------------
     rentsub |    482,279    .5108039    .5573595          0          2
     heatsub |    459,440    1.060121    .2377112          1          2
     heatval |    482,279    21.06813    119.7266          0     6667.8
    foodstmp |    482,279    1.179504    .3837742          1          2
    stampval |    482,279    447.1911    1326.326          0    27145.4
-------------+---------------------------------------------------------
    lunchsub |    482,279     .451554    .7169364          0          2
       nfams |    482,279    1.331549    .6506094          0         15
    nmothers |    482,279    .7009739    .6172458          0          5
      pernum |    482,279    1.802264    1.196774          1         21
      spmpov |     69,437    .2271123    .4189688          0          1
-------------+---------------------------------------------------------
       spmwt |     69,437    1550.174    959.3977      97.32    8761.64
 spmfedtaxac |     69,437    4112.597    15441.49     -17708     681967
     spmeitc |     69,437    892.1057    1604.491          0      13834
 spmfedtaxbc |     69,437    5527.522    14988.36          0     681967
   spmtotres |     69,437    44504.96    42769.24    -181979    1142270
-------------+---------------------------------------------------------
   spmthresh |     69,437    21773.46    9081.561    7790.45    87084.3
      wtsupp |    482,279    1618.138    968.4019          0   13006.53
      momloc |    482,279    .3838836    .8152799          0         14
     momrule |    482,279    .2250668    .4228421          0          7
      poploc |    482,279    .2134408    .5985862          0         14
-------------+---------------------------------------------------------
     poprule |    482,279    .1620742    .3991645          0          7
     famunit |    482,279    1.165054    .4385565          1         10
      relate |    482,279    337.4827    384.2682        101       1260
         age |    482,279    32.25502    8.260749         21         48
         sex |    482,279           2           0          2          2
-------------+---------------------------------------------------------
        race |    482,279    153.9013    136.3027        100        830
       marst |    482,279    5.154008    1.105773          3          6
      hispan |    482,279    38.25261    115.2898          0        902
        educ |    482,279    81.80689    22.86853          2        125
    schlcoll |    413,536    1.239321    2.041179          0          5
-------------+---------------------------------------------------------
    wkswork1 |    482,279    36.54342    21.30899          0         52
    uhrswork |    482,279    30.45406    17.55123          0         99
    wksunem1 |    482,279    77.26625    39.30095          0         99
       union |    365,992    .1654954    .4270549          0          3
     whynwly |    482,279    .5662075     1.26756          0          7
-------------+---------------------------------------------------------
      inctot |    482,279    28346.25    29787.89  -27922.03    1000000
     incwage |    482,279    23784.59    28136.73          0    1000000
      incbus |    482,279     631.805    6681.007  -29018.87   620292.1
     incfarm |    482,279    39.56502    3191.931  -17724.99   567390.4
       incss |    482,279     434.771    2601.648          0   76429.47
-------------+---------------------------------------------------------
    incwelfr |    482,279    534.7724    2182.011          0   57757.94
      incgov |    482,279    55.37515    758.6258          0   84811.61
    incaloth |    482,279    237.6197    2034.425          0   202646.6
    incretir |    482,279    56.05181    1223.192          0   175419.4
      incssi |    482,279    234.2391    1458.588          0   37118.71
-------------+---------------------------------------------------------
      incdrt |    482,279     55.7568    1568.695  -23663.23   181054.7
      incint |    482,279    325.7853    2480.328          0   190580.8
    incunemp |    482,279    164.2665    1300.122          0   111356.1
    incwkcom |    482,279    41.81635    880.8143          0   142612.3
      incvet |    482,279    22.67972    687.7182          0   100945.8
-------------+---------------------------------------------------------
     incsurv |    482,279    70.93593    2059.553          0   410131.5
    incdisab |    482,279    52.91148    1102.106          0   135265.4
    incdivid |    482,279    103.4101    1440.212          0   131458.7
     incrent |    482,279    95.25681     1946.07  -17722.85   154767.3
     inceduc |    482,279     422.947    2533.097          0   132833.6
-------------+---------------------------------------------------------
    incchild |    482,279    633.1464    2775.733          0   188252.2
     incalim |    482,279    75.27212    1587.142          0   188252.2
    incasist |    482,279    148.8082    1844.395          0   112851.1
    incother |    482,279    42.09659     836.555          0   106080.1
    mthwelfr |    389,386    .7207706     2.73269          0         12
-------------+---------------------------------------------------------
      offpov |    482,279    1.755544    .4297646          1          2
   offtotval |    482,279     35179.1    43176.59     -19998    1561447
   offcutoff |    482,279    12723.79    6089.156       3076      51844
     poverty |    482,279    19.59929    5.537599         10         23
    qincwage |    482,279    .0440969     .234007          0          3
-------------+---------------------------------------------------------
      hhsize |    482,279    3.060824    1.678024          1         26
     famsize |    482,279     2.63083    1.718914          1         25
     famkids |    482,279    1.008371     1.25065          0         14
  relate_201 |    482,279    .1573259    .3641082          0          1
  relate_501 |    482,279    .0445862    .2348432          0          2
-------------+---------------------------------------------------------
  relate_701 |    482,279    .0594884    .3067333          0         10
 relate_1001 |    482,279    .1364853    .5629021          0         14
 relate_1113 |    482,279    .0318032     .198319          0          7
 relate_1114 |    482,279     .105609    .3075864          0          3
 relate_1115 |    482,279    .0763977    .3840738          0         12
-------------+---------------------------------------------------------
 relate_1241 |    482,279    .0133823    .1619534          0         10
 relate_1260 |    482,279    .1393944    .5222877          0         16
      faminc |    482,279    49699.74    52993.24  -28529.21    1256226
    employed |    482,279    .7867811    .4095814          0          1
      female |    482,279           1           0          1          1
-------------+---------------------------------------------------------
         hgc |    482,279    13.13944    1.809551         11         17
   qualChild |    482,279    .7262083    1.096864          0         12
childAgeBi~1 |    482,279    .0527744    .2235831          0          1
childAgeBi~5 |    482,279    .1591651    .3658304          0          1
childAgeB~14 |    482,279    .2462123    .4308041          0          1
-------------+---------------------------------------------------------
childAgeB~24 |    482,279    .1227816    .3281867          0          1
      chldwt |    201,059     2799.97    2406.066          0   40977.49
    chldwage |    201,059    2238.138    8963.206          0     804586
     chldbus |    201,059    31.90782    1345.828  -18176.52   250740.2
    chldfarm |    201,059    3.663784    769.7508  -10479.03   258112.2
-------------+---------------------------------------------------------
      chldss |    201,059    203.9713    1598.465          0   74237.42
   chldwelfr |    201,059    58.81215     673.722          0   39297.74
     chldgov |    201,059    9.658172    288.7232          0   32916.48
   chldaloth |    201,059    40.32634    759.8323          0   112106.4
   chldretir |    201,059    3.106818    269.2525          0   56960.49
-------------+---------------------------------------------------------
     chldssi |    201,059    74.76985     833.153          0   40078.62
     chlddrt |    201,059    3.608166    259.3461  -4210.066   58071.09
     chldint |    201,059    32.24406    757.5918          0   130908.4
   chldunemp |    201,059    13.99924     340.617          0    33010.1
   chldwkcom |    201,059    3.383077    211.3056          0   43434.37
-------------+---------------------------------------------------------
     chldvet |    201,059    2.478394    138.7362          0   17895.95
    chldsurv |    201,059    10.37503    556.0354          0   98124.93
   chlddisab |    201,059     8.17434    401.3283          0   62876.38
   chlddivid |    201,059    7.022229    418.7944          0   108858.4
    chldrent |    201,059    6.543441    707.8029  -8708.673   158354.5
-------------+---------------------------------------------------------
    chldeduc |    201,059    157.6619    1550.926          0   96304.39
   chldchild |    201,059     34.0208    585.3806          0   70853.43
    chldalim |    201,059    .2954033    52.69369          0   16976.62
   chldasist |    201,059    4.564376    264.7774          0   53284.29
   chldother |    201,059    6.740756    232.4032          0   53703.48
-------------+---------------------------------------------------------
     chldtot |    201,059    2955.465    10181.09  -5429.297   871382.7
      famtot |    482,279    29578.36    30775.79  -27922.03    1000000
     famwage |    482,279    24717.66    28911.31          0    1000000
      fambus |    482,279    645.1071     6747.05  -29018.87   620292.1
     famfarm |    482,279    41.09243    3230.374  -17724.99   567390.4
-------------+---------------------------------------------------------
       famss |    482,279    519.8053    2936.821          0   82477.77
    famwelfr |    482,279    559.2908    2255.146          0   57757.93
      famgov |    482,279    59.40158     795.033          0   84811.61
    famaloth |    482,279    254.4315    2122.437          0   202646.6
    famretir |    482,279    57.34702    1240.565          0   175419.4
-------------+---------------------------------------------------------
      famssi |    482,279    265.4102    1589.188          0   59640.81
      famdrt |    482,279    57.26102    1591.009  -23663.23   181054.7
      famint |    482,279    339.2276    2555.031          0     195065
    famunemp |    482,279    170.1027    1322.375          0   111356.1
    famwkcom |    482,279    43.22673    892.6274          0   142612.3
-------------+---------------------------------------------------------
      famvet |    482,279    23.71295     699.813          0   100945.8
     famsurv |    482,279    75.26121    2097.626          0   410131.5
    famdisab |    482,279    56.31931    1133.045          0   135265.4
    famdivid |    482,279    106.3376    1478.979          0   181430.7
     famrent |    482,279    97.98473    2012.757  -17722.85   237531.7
-------------+---------------------------------------------------------
     fameduc |    482,279    488.6752    2722.601          0   132833.6
    famchild |    482,279    647.3294    2803.164          0   188252.2
     famalim |    482,279    75.39527    1587.767          0   188252.2
    famasist |    482,279    150.7111    1858.969          0   112851.1
    famother |    482,279    44.90676    856.4265          0   106080.1
-------------+---------------------------------------------------------
       state |    482,279    24.59953    14.60863          1         51
        agex |    482,279           0           0          0          0
      fiitax |    482,279    2366.964    7307.975  -8756.369     339339
      siitax |    482,279    707.5926    1640.243  -2613.392   64178.73
        fica |    482,279    3523.534    3531.938          0    50298.8
-------------+---------------------------------------------------------
   fedRegTax |    482,279    3061.901    6965.015          0     339339
         ctc |    482,279    135.8821    442.6385          0   6330.353
        actc |    482,279    60.38463    296.2727          0   4723.488
      fedEIC |    482,279    478.1492    1127.061          0   6142.706
       stEIC |    482,279    23.04475    141.4916          0   3026.595
-------------+---------------------------------------------------------
fedRegTax_ly |    482,279    3095.175     7037.71          0   304919.8
      ctc_ly |    482,279    129.8944    432.2301          0   6330.353
     actc_ly |    482,279     53.0331    276.4171          0   4665.529
   fedEIC_ly |    482,279    465.6475    1109.047          0   6142.706
    stEIC_ly |    482,279    21.57654     137.134          0   3071.353
-------------+---------------------------------------------------------
         cpi |    482,279    162.4089    45.39653       72.6    232.957
        atti |    482,279    22216.42    19103.89  -27745.67   560750.2

. save cpsAfterTaxsim_singleRestrictions, replace ;
file cpsAfterTaxsim_singleRestrictions.dta saved

. */
> *;
. disp "`beginTime'" ;
DateTime: 16 Apr 2018 10:10:53

. disp "DateTime: $S_DATE $S_TIME";
DateTime: 16 Apr 2018 10:23:19

. log close ;
      name:  <unnamed>
       log:  5_SingleRestrictions_ReadInCps.log
  log type:  text
 closed on:  16 Apr 2018, 10:23:19
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
